<?php
$nowdate=date('Y-m-d');
if(empty($RTLS1)) { $date_result="0"; }
else
{
$mydate=$RTLS1->TANGGAL;

$year_format1=date("Y", strtotime($nowdate));
$year_format2=date("Y", strtotime($mydate));
$year_result=($year_format1-$year_format2)*12; 

$month_format1=date("m", strtotime($mydate));
$month_format2 = strtotime("-".$month_format1." month",strtotime($nowdate));
$month_format3=date("m", strtotime($nowdate));
if($month_format3==$month_format1) { $month_result="0"; } else { $month_result = date("m", $month_format2); }

$date_result=$year_result+$month_result;
}
?>
<div class="form-group">
 <div class="container">
 
<form class="form-horizontal" role="form" action="<?php echo site_url('haspem/input_form');?>" method="post">
 <table class="table table-bordered table-condensed">
 <thead>
        <tr>
          <th>No</th>
          <th>Temuan</th>
          <th>Rencana Tindak Lanjut</th>
          <th>Target Penyelesaian</th>
		  <th>Keterangan</th>
        </tr>
      </thead>
	  <tbody>
        <tr>
		<td>I</td>
          <td><b>Sikap Tidak Aman</b></td>
          </td>
 <td>
 </td>
 <td>
 </td>
        </tr>
		<tr>
		<?php
		if(empty($RTLS1)) { $RTLS1_1=""; $RTLS1_2=""; $RTLS1_3=""; $RTLS1_4=""; }
		else if($RTLS1->TBS1+$date_result>2) { $RTLS1_1=$RTLS1->S1."\" readonly=\"readonly"; $RTLS1_2=$RTLS1->KETS1; $RTLS1_3=$RTLS1->TLS1."\" readonly=\"readonly"; $RTLS1_4=""; } else { $RTLS1_1=""; $RTLS1_2=""; $RTLS1_3=""; $RTLS1_4=""; }
		
		if(empty($RTLS2)) { $RTLS2_1=""; $RTLS2_2=""; $RTLS2_3=""; $RTLS2_4=""; }
		else if($RTLS2->TBS2+$date_result>2) { $RTLS2_1=$RTLS2->S2."\" readonly=\"readonly"; $RTLS2_2=$RTLS2->KETS2; $RTLS2_3=$RTLS2->TLS2."\" readonly=\"readonly"; $RTLS2_4=""; } else { $RTLS2_1=""; $RTLS2_2=""; $RTLS2_3=""; $RTLS2_4=""; }
		
		if(empty($RTLS3)) { $RTLS3_1=""; $RTLS3_2=""; $RTLS3_3=""; $RTLS3_4=""; }
		else if($RTLS3->TBS3+$date_result>2) { $RTLS3_1=$RTLS3->S3."\" readonly=\"readonly"; $RTLS3_2=$RTLS3->KETS3; $RTLS3_3=$RTLS3->TLS3."\" readonly=\"readonly"; $RTLS3_4=""; } else { $RTLS3_1=""; $RTLS3_2=""; $RTLS3_3=""; $RTLS3_4=""; }
		
		if(empty($RTLS4)) { $RTLS4_1=""; $RTLS4_2=""; $RTLS4_3=""; $RTLS4_4=""; }
		else if($RTLS4->TBS4+$date_result>2) { $RTLS4_1=$RTLS4->S4."\" readonly=\"readonly"; $RTLS4_2=$RTLS4->KETS4; $RTLS4_3=$RTLS4->TLS4."\" readonly=\"readonly"; $RTLS4_4=""; } else { $RTLS4_1=""; $RTLS4_2=""; $RTLS4_3=""; $RTLS4_4=""; }
		
		if(empty($RTLS5)) { $RTLS5_1=""; $RTLS5_2=""; $RTLS5_3=""; $RTLS5_4=""; }
		else if($RTLS5->TBS5+$date_result>2) { $RTLS5_1=$RTLS5->S5."\" readonly=\"readonly"; $RTLS5_2=$RTLS5->KETS5; $RTLS5_3=$RTLS5->TLS5."\" readonly=\"readonly"; $RTLS5_4=""; } else { $RTLS5_1=""; $RTLS5_2=""; $RTLS5_3=""; $RTLS5_4=""; }
		?>
		<td></td>
		<td><input class="form-control" id="sta1" type="text" name="sta1" maxlength="50" value="<?php echo $RTLS1_1; ?>" /></br>
		<input class="form-control" id="sta2" type="text" name="sta2" maxlength="50" value="<?php echo $RTLS2_1; ?>" /></br>
		<input class="form-control" id="sta3" type="text" name="sta3" maxlength="50" value="<?php echo $RTLS3_1; ?>" /></br>
		<input class="form-control" id="sta4" type="text" name="sta4" maxlength="50" value="<?php echo $RTLS4_1; ?>" /></br>
		<input class="form-control" id="sta5" type="text" name="sta5" maxlength="50" value="<?php echo $RTLS5_1; ?>" /></td>
		<td><input class="form-control" id="rtl0" type="text" name="rtl0" maxlength="50" value="<?php echo $RTLS1_3; ?>" /></br>
		<input class="form-control" id="rtl1" type="text" name="rtl1" maxlength="50" value="<?php echo $RTLS2_3; ?>" /></br>
		<input class="form-control" id="rtl2" type="text" name="rtl2" maxlength="50" value="<?php echo $RTLS3_3; ?>" /></br>
		<input class="form-control" id="rtl3" type="text" name="rtl3" maxlength="50" value="<?php echo $RTLS4_3; ?>" /></br>
		<input class="form-control" id="rtl4" type="text" name="rtl4" maxlength="50" value="<?php echo $RTLS5_3; ?>" /></td>
		<td><input class="form-control" id="datepicker1" type="text" name="tar1" maxlength="50" value="<?php echo $RTLS1_4; ?>" /></br>
		<input class="form-control" id="datepicker2" type="text" name="tar2" maxlength="50" value="<?php echo $RTLS2_4; ?>" /></br>
		<input class="form-control" id="datepicker3" type="text" name="tar3" maxlength="50" value="<?php echo $RTLS3_4; ?>" /></br>
		<input class="form-control" id="datepicker4" type="text" name="tar4" maxlength="50" value="<?php echo $RTLS4_4; ?>" /></br>
		<input class="form-control" id="datepicker5" type="text" name="tar5" maxlength="50" value="<?php echo $RTLS5_4; ?>" /></td>
		<td>
		<input class="form-control" id="ket1" type="text" name="ket1" maxlength="50" value="<?php echo $RTLS1_2; ?>" /></br>
		<input class="form-control" id="ket2" type="text" name="ket2" maxlength="50" value="<?php echo $RTLS2_2; ?>" /></br>
		<input class="form-control" id="ket3" type="text" name="ket3" maxlength="50" value="<?php echo $RTLS3_2; ?>" /></br>
		<input class="form-control" id="ket4" type="text" name="ket4" maxlength="50" value="<?php echo $RTLS4_2; ?>" /></br>
		<input class="form-control" id="ket5" type="text" name="ket5" maxlength="50" value="<?php echo $RTLS5_2; ?>" />
</td>
		
		</tr>
		
		<tr>
		<td>II</td>
          <td><b>Kondisi Tidak Aman</b></td>
          </td>
 <td>
 </td>
 <td>
 </td>
        </tr>
		<tr>
		<?php
		if(empty($RTLK1)) { $RTLK1_1=""; $RTLK1_2=""; $RTLK1_3=""; $RTLK1_4=""; }
		else if($RTLK1->TBK1+$date_result>2) { $RTLK1_1=$RTLK1->K1."\" readonly=\"readonly"; $RTLK1_2=$RTLK1->KETK1; $RTLK1_3=$RTLK1->TLK1."\" readonly=\"readonly"; $RTLK1_4=""; } else { $RTLK1_1=""; $RTLK1_2=""; $RTLK1_3=""; $RTLK1_4=""; }
		
		if(empty($RTLK2)) { $RTLK2_1=""; $RTLK2_2=""; $RTLK2_3=""; $RTLK2_4=""; }
		else if($RTLK1->TBK1+$date_result>2) { $RTLK2_1=$RTLK2->K2."\" readonly=\"readonly"; $RTLK2_2=$RTLK2->KETK2; $RTLK2_3=$RTLK2->TLK2."\" readonly=\"readonly"; $RTLK2_4=""; } else { $RTLK2_1=""; $RTLK2_2=""; $RTLK2_3=""; $RTLK2_4=""; }
		
		if(empty($RTLK3)) { $RTLK3_1=""; $RTLK3_2=""; $RTLK3_3=""; $RTLK3_4=""; }
		else if($RTLK1->TBK1+$date_result>2) { $RTLK3_1=$RTLK3->K3."\" readonly=\"readonly"; $RTLK3_2=$RTLK3->KETK3; $RTLK3_3=$RTLK3->TLK3."\" readonly=\"readonly"; $RTLK3_4=""; } else { $RTLK3_1=""; $RTLK3_2=""; $RTLK3_3=""; $RTLK3_4=""; }
		
		if(empty($RTLK4)) { $RTLK4_1=""; $RTLK4_2=""; $RTLK4_3=""; $RTLK4_4=""; }
		else if($RTLK1->TBK1+$date_result>2) { $RTLK4_1=$RTLK4->K4."\" readonly=\"readonly"; $RTLK4_2=$RTLK4->KETK4; $RTLK4_3=$RTLK4->TLK4."\" readonly=\"readonly"; $RTLK4_4=""; } else { $RTLK4_1=""; $RTLK4_2=""; $RTLK4_3=""; $RTLK4_4=""; }
		
		if(empty($RTLK5)) { $RTLK5_1=""; $RTLK5_2=""; $RTLK5_3=""; $RTLK5_4=""; }
		else if($RTLK1->TBK1+$date_result>2) { $RTLK5_1=$RTLK5->K5."\" readonly=\"readonly"; $RTLK5_2=$RTLK5->KETK5; $RTLK5_3=$RTLK5->TLK5."\" readonly=\"readonly"; $RTLK5_4=""; } else { $RTLK5_1=""; $RTLK5_2=""; $RTLK5_3=""; $RTLK5_4=""; }
		?>
		<td></td>
		<td><input class="form-control" id="kta1" type="text" name="kta1" maxlength="50" value="<?php echo $RTLK1_1; ?>" /></br>
		<input class="form-control" id="kta2" type="text" name="kta2" maxlength="50" value="<?php echo $RTLK2_1; ?>" /></br>
		<input class="form-control" id="kta3" type="text" name="kta3" maxlength="50" value="<?php echo $RTLK3_1; ?>" /></br>
		<input class="form-control" id="kta4" type="text" name="kta4" maxlength="50" value="<?php echo $RTLK4_1; ?>" /></br>
		<input class="form-control" id="kta5" type="text" name="kta5" maxlength="50" value="<?php echo $RTLK5_1; ?>" /></td>
		<td><input class="form-control" id="rtl6" type="text" name="rt5" maxlength="50" value="<?php echo $RTLK1_3; ?>" /></br>
		<input class="form-control" id="rtl7" type="text" name="rt6" maxlength="50" value="<?php echo $RTLK2_3; ?>" /></br>
		<input class="form-control" id="rtl8" type="text" name="rt7" maxlength="50" value="<?php echo $RTLK3_3; ?>" /></br>
		<input class="form-control" id="rtl9" type="text" name="rt8" maxlength="50" value="<?php echo $RTLK4_3; ?>" /></br>
		<input class="form-control" id="rtl10" type="text" name="rt9" maxlength="50" value="<?php echo $RTLK5_3; ?>" /></td>
		<td><input class="form-control" id="datepicker6" type="text" name="tar6" maxlength="50" value="<?php echo $RTLK1_4; ?>" /></br>
		<input class="form-control" id="datepicker7" type="text" name="tar7" maxlength="50" value="<?php echo $RTLK2_4; ?>" /></br>
		<input class="form-control" id="datepicker8" type="text" name="tar8" maxlength="50" value="<?php echo $RTLK3_4; ?>" /></br>
		<input class="form-control" id="datepicker9" type="text" name="tar9" maxlength="50" value="<?php echo $RTLK4_4; ?>" /></br>
		<input class="form-control" id="datepicker10" type="text" name="tar10" maxlength="50" value="<?php echo $RTLK5_4; ?>" /></td>
		<td>
		<input class="form-control" id="ket6" type="text" name="ket6" maxlength="50" value="<?php echo $RTLK1_2; ?>" /></br>
		<input class="form-control" id="ket7" type="text" name="ket7" maxlength="50" value="<?php echo $RTLK2_2; ?>" /></br>
		<input class="form-control" id="ket8" type="text" name="ket8" maxlength="50" value="<?php echo $RTLK3_2; ?>" /></br>
		<input class="form-control" id="ket9" type="text" name="ket9" maxlength="50" value="<?php echo $RTLK4_2; ?>" /></br>
		<input class="form-control" id="ket10" type="text" name="ket10" maxlength="50" value="<?php echo $RTLK5_2; ?>" />
</td>
		
		</tr>
		
		<tr>
		<td>III</td>
          <td><b>Lingkungan Kerja</b></td>
          </td>
 <td>
 </td>
 <td>
 </td>
        </tr>
		<tr>
		<?php
		if(empty($RTLG1)) { $RTLG1_1=""; $RTLG1_2=""; $RTLG1_3=""; $RTLG1_4=""; }
		else if($RTLG1->TBG1+$date_result>2) { $RTLG1_1=$RTLG1->G1."\" readonly=\"readonly"; $RTLG1_2=$RTLG1->KETG1; $RTLG1_3=$RTLG1->TLG1."\" readonly=\"readonly"; $RTLG1_4=""; } else { $RTLG1_1=""; $RTLG1_2=""; $RTLG1_3=""; $RTLG1_4=""; }
		
		if(empty($RTLG2)) { $RTLG2_1=""; $RTLG2_2=""; $RTLG2_3=""; $RTLG2_4=""; }
		else if($RTLG2->TBG2+$date_result>2) { $RTLG2_1=$RTLG2->G2."\" readonly=\"readonly"; $RTLG2_2=$RTLG2->KETG2; $RTLG2_3=$RTLG2->TLG2."\" readonly=\"readonly"; $RTLG2_4=""; } else { $RTLG2_1=""; $RTLG2_2=""; $RTLG2_3=""; $RTLG2_4=""; }
		
		if(empty($RTLG3)) { $RTLG3_1=""; $RTLG3_2=""; $RTLG3_3=""; $RTLG3_4=""; }
		else if($RTLG3->TBG3+$date_result>2) { $RTLG3_1=$RTLG3->G3."\" readonly=\"readonly"; $RTLG3_2=$RTLG3->KETG3; $RTLG3_3=$RTLG3->TLG3."\" readonly=\"readonly"; $RTLG3_4=""; } else { $RTLG3_1=""; $RTLG3_2=""; $RTLG3_3=""; $RTLG3_4=""; }
		
		if(empty($RTLG4)) { $RTLG4_1=""; $RTLG4_2=""; $RTLG4_3=""; $RTLG4_4=""; }
		else if($RTLG4->TBG4+$date_result>2) { $RTLG4_1=$RTLG4->G4."\" readonly=\"readonly"; $RTLG4_2=$RTLG4->KETG4; $RTLG4_3=$RTLG4->TLG4."\" readonly=\"readonly"; $RTLG4_4=""; } else { $RTLG4_1=""; $RTLG4_2=""; $RTLG4_3=""; $RTLG4_4=""; }
		
		if(empty($RTLG5)) { $RTLG5_1=""; $RTLG5_2=""; $RTLG5_3=""; $RTLG5_4=""; }
		else if($RTLG5->TBG5+$date_result>2) { $RTLG5_1=$RTLG5->G5."\" readonly=\"readonly"; $RTLG5_2=$RTLG5->KETG5; $RTLG5_3=$RTLG5->TLG5."\" readonly=\"readonly"; $RTLG5_4=""; } else { $RTLG5_1=""; $RTLG5_2=""; $RTLG5_3=""; $RTLG5_4=""; }
		?>
		<td></td>
		<td><input class="form-control" id="lk1" type="text" name="lk1" maxlength="50" value="<?php echo $RTLG1_1; ?>" /></br>
		<input class="form-control" id="lk2" type="text" name="lk2" maxlength="50" value="<?php echo $RTLG2_1; ?>" /></br>
		<input class="form-control" id="lk3" type="text" name="lk3" maxlength="50" value="<?php echo $RTLG3_1; ?>" /></br>
		<input class="form-control" id="lk4" type="text" name="lk4" maxlength="50" value="<?php echo $RTLG4_1; ?>" /></br>
		<input class="form-control" id="lk5" type="text" name="lk5" maxlength="50" value="<?php echo $RTLG5_1; ?>" /></td>
		<td><input class="form-control" id="rtl11" type="text" name="rt11" maxlength="50" value="<?php echo $RTLG1_3; ?>" /></br>
		<input class="form-control" id="rtl12" type="text" name="rt12" maxlength="50" value="<?php echo $RTLG2_3; ?>" /></br>
		<input class="form-control" id="rtl13" type="text" name="rt13" maxlength="50" value="<?php echo $RTLG3_3; ?>" /></br>
		<input class="form-control" id="rtl14" type="text" name="rt14" maxlength="50" value="<?php echo $RTLG4_3; ?>" /></br>
		<input class="form-control" id="rtl15" type="text" name="rt15" maxlength="50" value="<?php echo $RTLG5_3; ?>" /></td>
		<td><input class="form-control" id="datepicker11" type="text" name="tar11" maxlength="50" value="<?php echo $RTLG1_4; ?>" /></br>
		<input class="form-control" id="datepicker12" type="text" name="tar12" maxlength="50" value="<?php echo $RTLG2_4; ?>" /></br>
		<input class="form-control" id="datepicker13" type="text" name="tar13" maxlength="50" value="<?php echo $RTLG3_4; ?>" /></br>
		<input class="form-control" id="datepicker14" type="text" name="tar14" maxlength="50" value="<?php echo $RTLG4_4; ?>" /></br>
		<input class="form-control" id="datepicker15" type="text" name="tar15" maxlength="50" value="<?php echo $RTLG5_4; ?>" /></td>
		<td>
		<input class="form-control" id="ket11" type="text" name="ket11" maxlength="50" value="<?php echo $RTLG1_2; ?>" /></br>
		<input class="form-control" id="ket12" type="text" name="ket12" maxlength="50" value="<?php echo $RTLG2_2; ?>" /></br>
		<input class="form-control" id="ket13" type="text" name="ket13" maxlength="50" value="<?php echo $RTLG3_2; ?>" /></br>
		<input class="form-control" id="ket14" type="text" name="ket14" maxlength="50" value="<?php echo $RTLG4_2; ?>" /></br>
		<input class="form-control" id="ket15" type="text" name="ket15" maxlength="50" value="<?php echo $RTLG5_2; ?>" />
</td>
		
		</tr>
		</table>
		NIK Anggota     </br>
        <input class="form-control" id="nama1" type="text" name="nama1" maxlength="50" value="" required />
        <input class="form-control" id="nama2" type="hidden" name="nama2" maxlength="50" value=""/>
</br></br>
		<?php
		if($this->session->userdata('role')==1)
		{
		?>
		Pengawas Telah Memvalidasi
		<input disabled name="pengawas" type="checkbox" value="1"></br></br>
		Sekretaris Telah Memvalidasi
		<input disabled name="skertaris" type="checkbox" value="1"></br></br>
		<?php
		}
		else
		{
		?>
		Pengawas Telah Memvalidasi
		<input name="pengawas" type="checkbox" value="1"></br></br>
		Sekretaris Telah Memvalidasi
		<input name="skertaris" type="checkbox" value="1"></br></br>
		<?php
		}
		?>
		<input type="submit" class="btn btn-primary" value="Kirim"/></div>
		</form>
		
		</div></body></html>